
const reqPr = function (url, config) {
	let { data, headers, method } = config;
	url = `https://api.mch.weixin.qq.com/${url}`;
	console.log(data);
	return new Promise ((resolve, reject) => {
		let queryData = data;
		
		uni.request({
			url: url,
			data: queryData,
			header: headers,
			method: method || 'GET',
			success: function(res) {
				resolve(res.data)
			},
			fail: (err) => {
				reject(err);
			},
			
		})
	});
}

export default {
	post: ({url, data, contentType,Authorization}) => {
		data = data || {}
		let headers = {};
		headers['content-type'] = contentType || 'application/json';
		headers['Authorization'] = Authorization || '';
		headers['Accept'] = 'application/json';
		headers['Accept-Language'] = 'zh-CN';
		let pr =  reqPr(url, { data, headers, method: 'POST' });
		return pr;
	},
	get: ({url, data,contentType,Authorization}) => {
		data = data || {}
		let headers = {};
        // headers['content-type'] = contentType || 'application/json';
		headers['Authorization'] = Authorization || '';
		headers['Accept'] = 'application/json';
		headers['Accept-Language'] = 'zh-CN';
		return reqPr(url, { data, headers});
	},
}
